<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p class="btn">add</p>
    <p class="btn">add</p>
    <p class="btn">add</p>
    <p class="btn">add</p>
    <p class="btn">add</p>
    <p class="btn">add</p>
    <p class="btn">add</p>
    <p class="btn">add</p>
    <p class="btn">add</p>
    <p class="btn">add</p>
</body>
<script>
    var btns = document.getElementsByClassName('btn');
    for (let i = 0; i < btns.length; i++) {
        const element = btns[i];
        console.log('i', i);
    }

    for (let i = 0, l = btns.length; i < l; i++) {
        const element = btns[i];
        console.log('i', i);
    }

</script>
</html>